<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Array对象 </title>
    <script type="text/javascript">
        function sortNum(a, b) {
            return a - b;
            //升序，如降序，把“a - b”该成“b - a”
        }

        function sortNumSmaller(a, b) {
            return b - a;
        }

        var myarr = new Array("80", "16", "50", "6", "100", "1");
        document.write(myarr + "<br>");
        //升序
        document.write(myarr.sort(sortNum) + "<br>");
        //使用sort()方法，进行数组降序列排列，并输出。
        document.write(myarr.sort(sortNumSmaller) + "<br>");
    </script>
</head>
<body>
</body>
</html>